package org.dreamwork.assistant.tools.network.gui;

import java.io.IOException;
import java.io.OutputStream;
import java.net.Socket;

/**
 * Created by seth.yang on 2018/5/7
 */
public class TcpAdapter implements INetworkAdapter {
    private Socket socket;
    private OutputStream out;

    TcpAdapter (Socket socket) throws IOException {
        if (socket != null) {
            this.socket = socket;
            this.out = socket.getOutputStream ();
        }
    }

    @Override
    public void write (byte[] data) throws IOException {
        out.write (data);
    }

    @Override
    public void close () throws IOException {
        if (socket != null) {
            socket.close ();
        }
    }
}